<%@ include file="/common/taglibs.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"
	dir="ltr">
	<head>

		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" href="<c:url value="/css/shopadmin.css"/>"
			type="text/css" />

	</head>
	<body style="">
		<div id="headBar" class="head_content">
			<div class="finder-action" id=" ">
				<div class="finder-action-inner clearfix">
					<button type="button" onclick="location.href='mb_level_add.html'"
						class="btn btn-large">
						<span><span><i class="finder-icon"><img
										src="<c:url value="/images/transparent.gif"/>"
										class="imgbundle icon"
										style="width: 24px; height: 24px; background-position: 0pt -316px;">
							</i>添加等级</span> </span>
					</button>
					<button type="button" onclick="location.reload();" class="btn">
						<span><span><i class="finder-icon"><img
										src="<c:url value="/images/transparent.gif"/>"
										class="imgbundle icon"
										style="width: 22px; height: 24px; background-position: 0pt -644px;">
							</i>刷新</span> </span>
					</button>
					<button type="button" onclick="levelBatchDelete()" class="btn">
						<span><span><i class="finder-icon"><img
										src="<c:url value="/images/transparent.gif"/>"
										class="imgbundle icon"
										style="width: 17px; height: 24px; background-position: 0pt -757px;">
							</i>删除</span> </span>
					</button>
				</div>
			</div>

			<div class="finder-header">
				
				<table cellpadding="0" cellspacing="0" width="100%">
					<!----cols---->
					<col style="width: 24px;" class="span-select" />
					<col style="width: 48px;" />
					<col style="width: 110px;" />
					<col style="width: 110px;" />
					<col style="width: 110px;" />
					<col style="" />
					<col />
					<!----cols---->
					<thead>
						<tr>
							<td>
								<input class="sellist"  id="level_ids" type="checkbox" />
							</td>
							<td style="width: 48px;">
								&nbsp;查看
							</td>
							<td>
								<div class="cell orderable" key="name">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">等级名称</span>
												</td>

											</tr>
										</tbody>
									</table>
								</div>
							</td>
							
							<td>
								<div class="cell orderable" key="dis_count">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">优惠折扣率</span>
												</td>

											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="default_lv">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">是否默认</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div class="cell orderable" key="experience">
									<table cellpadding="0" cellspacing="0" width="100%">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">经验值</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								&nbsp;
							</td>
						</tr>
					</thead>
				</table>
			</div>

		</div>
		<div id="main" class="main_content">
			<form   method="post"
				action="<c:url value="mb_level_delete.html"/> " id="levelListForm">
			<div class="finder-list finder-list-normal">
				<table cellpadding="0" cellspacing="0" width="100%" id="levelList_table">
					<!----cols---->
					<col style="width: 24px;" class="span-select" />
					<col style="width: 48px;" />
					<col style="width: 110px;" />
					<col style="width: 110px;" />
					<col style="width: 110px;" />
					<col style="" />
					<col />
					<!----cols---->
					<c:forEach var="memberLevel" items="${memberLevels}" varStatus="levelIndex">
						<tr class="row" item-id="1">
							<td>
								<input onclick="changeColor(this)"  class="sel" name="memberLevels[${levelIndex.index}].mlId"  value="${memberLevel.mlId}"	 type="checkbox" />
								<input   name="memberLevels[${levelIndex.index}].name" value="${memberLevel.name}"	 type="hidden" />
								
							</td>
							<td class="finder-list-command">
								<a 
									href="mb_level_edit.html?mlId =${memberLevel.mlId}" >
									<img src="<c:url value="/images/transparent.gif"/>"
										class="imgbundle"
										style="width: 16px; height: 16px; background-position: 0pt -1811px;" />
								</a>
							</td>
							<td key="name" class="editable">
								<div class="cell">
									${memberLevel.name}
								</div>
							</td>
							<td key="dis_count" class="editable">
								<div class="cell">
									${memberLevel.disCount}%
								</div>
							</td>
							<td key="default_lv">
								<div class="cell">
									<c:if test="${memberLevel.defaultLevel}">是</c:if>
									<c:if test="${!memberLevel.defaultLevel}">否</c:if>
								</div>
							</td>
							<td key="experience">
								<div class="cell">
									${memberLevel.experience }
								</div>
							</td>
							<td>
								&nbsp;
							</td>
						</tr>

					</c:forEach>
				</table>
				
			</div>
			</form>
		</div>
		<div   id="footBar" class="foot_content">
			<div class="finder-footer" id=" ">
				<div class="finder-page clearfix">
					<div class="span-3">
						 &nbsp;
					</div>
					<div class="span-auto"></div>
					<div class="span-auto textright">
						共<i>${fn:length(memberLevels)}</i>条
					</div>
				</div>
			</div>
			<div   class="finder-detail" >
				<div class="finder-detail-content" container="true">
				</div>
			</div>
		</div>
		<script type="text/javascript"
			src="<c:url value='/scripts/jquery-1.4.2.js'/>"></script>
		<%@ include file="/jsp/admin/common/messages.jsp"%>
		<script type="text/javascript">
			var selected = 'selected'; 
	$("#level_ids").click(function() {
		
		if (this.checked) {
			$('input[type=checkbox]').attr("checked", true);
			
			$('#levelList_table > tr').addClass(selected);
		} else {
			$('input[type=checkbox]').attr("checked", false);
			$('#levelList_table  > tr').removeClass(selected);
		}
	});
	
	function changeColor(obj){		
		if($(obj).attr("checked")){			
			$(obj).parent().parent().addClass(selected);				
		}else{
			$(obj).parent().parent().removeClass(selected);
		}	
	}
	
	
	function levelBatchDelete(){
		var selected = false;
		$('#levelList_table input[type=checkbox]').each( function(i, dom){
			if($(dom).attr("checked")){
				selected = true;
			}							
		});	
		if(!selected){
			alert('请选择要删除的等级');
			return;
		}
		if(!confirm("确定删除吗？")){
			return;
		}						
		$('#levelListForm').submit();
	}
		</script>
	</body>
</html>